/**
 * 
 */
package travibot.utility;

import java.util.Locale;

import org.apache.log4j.Logger;

import travibot.resource.ResourceHelper;

/**
 * Loaded at startup and selecting instance locale from the properties file.
 * 
 * @author Petr Macek
 * 
 */
public class LocaleSelector {

    private static final String COUNTRY_KEY = "locale.country";

    private static final String LANG_KEY = "locale.language";

    private static Logger log = Logger.getLogger(LocaleSelector.class);

    private static final String SETTINGS_FILE = "locale_settings";

    private final Locale locale;

    public LocaleSelector() {

        String keyLang = ResourceHelper.getKeyValue(SETTINGS_FILE, LANG_KEY);
        String keyCountry = ResourceHelper.getKeyValue(SETTINGS_FILE, COUNTRY_KEY);
        locale = new Locale(keyLang, keyCountry);
        log.info("Selecting locale " + locale);
    }

    public Locale getLocale() {

        return locale;
    }

}
